package edu.scau.pro.hotel.service.impl;

import edu.scau.pro.hotel.entity.HotelDateDiscount;
import edu.scau.pro.hotel.mapper.HotelDateDiscountMapper;
import edu.scau.pro.hotel.service.IHotelDateDiscountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HotelDateDiscount)表服务实现类
 *
 * @author CJW
 * @since 2022-04-24 13:16:38
 */
@Service("hotelDateDiscountService")
public class HotelDateDiscountServiceImpl implements IHotelDateDiscountService {
    @Resource
    private HotelDateDiscountMapper hotelDateDiscountMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param dateDiscountId 主键
     * @return 实例对象
     */
    @Override
    public HotelDateDiscount queryById(Integer dateDiscountId) {
        return this.hotelDateDiscountMapper.queryById(dateDiscountId);
    }

    /**
     * 查询指定行
     *
     * @param hotelDateDiscount 筛选条件
     * @return 查询结果
     */
    @Override
    public List<HotelDateDiscount> queryAll(HotelDateDiscount hotelDateDiscount) {
        return this.hotelDateDiscountMapper.queryAll(hotelDateDiscount);
    }

    /**
     * 新增数据
     *
     * @param hotelDateDiscount 实例对象
     * @return 实例对象
     */
    @Override
    public HotelDateDiscount insert(HotelDateDiscount hotelDateDiscount) {
        this.hotelDateDiscountMapper.insert(hotelDateDiscount);
        return hotelDateDiscount;
    }

    /**
     * 修改数据
     *
     * @param hotelDateDiscount 实例对象
     * @return 实例对象
     */
    @Override
    public HotelDateDiscount update(HotelDateDiscount hotelDateDiscount) {
        this.hotelDateDiscountMapper.update(hotelDateDiscount);
        return this.queryById(hotelDateDiscount.getDateDiscountId());
    }

    /**
     * 通过主键删除数据
     *
     * @param dateDiscountId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer dateDiscountId) {
        return this.hotelDateDiscountMapper.deleteById(dateDiscountId) > 0;
    }
}
